﻿/*
#------------------------------------------------------------------------------
#-- Program Name:	[dbo].[spRestoreDatabase_GetLastLabel]
#-- Purpose:		Determines the most recent backup label
#--	Last Update:	01/09/2012
#--					For a complete history - please review comments in SVN
#------------------------------------------------------------------------------
*/
CREATE PROCEDURE [dbo].[spRestoreDatabase_GetLastLabel]
(
	@database_name		sysname
)
AS

SET NOCOUNT ON

SELECT		TOP 1 name 
FROM		msdb.dbo.backupset 
WHERE		database_name = @database_name
			AND name IS NOT NULL 
			AND name NOT IN ('PRE_Restore', 'POST_Restore')
ORDER BY	backup_set_id DESC

SET NOCOUNT OFF
